package org.centny.baccara;

import org.centny.bb.BaccaratBuilder;

/**
 * Poker reference class.
 * 
 * @author Scorpion
 * 
 */
public class Poker {
	/**
	 * count the poker card id.
	 * 
	 * @param c
	 *            the card byte.
	 * @return poker card image id.
	 */
	public static int card(byte c) {
		int[] cinfo = BaccaratBuilder.card(c);
		if (cinfo.length != 2 || cinfo[0] < 0 || cinfo[1] < 0 || cinfo[0] > 12
				|| cinfo[1] > 3) {
			throw new RuntimeException("invalid card");
		}
		switch (cinfo[0]) {
		case 0:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_1_1;
			case 1:
				return R.drawable.c_1_2;
			case 2:
				return R.drawable.c_1_3;
			case 3:
				return R.drawable.c_1_4;
			}
			break;
		case 1:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_2_1;
			case 1:
				return R.drawable.c_2_2;
			case 2:
				return R.drawable.c_2_3;
			case 3:
				return R.drawable.c_2_4;
			}
			break;
		case 2:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_3_1;
			case 1:
				return R.drawable.c_3_2;
			case 2:
				return R.drawable.c_3_3;
			case 3:
				return R.drawable.c_3_4;
			}
			break;
		case 3:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_4_1;
			case 1:
				return R.drawable.c_4_2;
			case 2:
				return R.drawable.c_4_3;
			case 3:
				return R.drawable.c_4_4;
			}
			break;
		case 4:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_5_1;
			case 1:
				return R.drawable.c_5_2;
			case 2:
				return R.drawable.c_5_3;
			case 3:
				return R.drawable.c_5_4;
			}
			break;
		case 5:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_6_1;
			case 1:
				return R.drawable.c_6_2;
			case 2:
				return R.drawable.c_6_3;
			case 3:
				return R.drawable.c_6_4;
			}
			break;
		case 6:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_7_1;
			case 1:
				return R.drawable.c_7_2;
			case 2:
				return R.drawable.c_7_3;
			case 3:
				return R.drawable.c_7_4;
			}
			break;
		case 7:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_8_1;
			case 1:
				return R.drawable.c_8_2;
			case 2:
				return R.drawable.c_8_3;
			case 3:
				return R.drawable.c_8_4;
			}
			break;
		case 8:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_9_1;
			case 1:
				return R.drawable.c_9_2;
			case 2:
				return R.drawable.c_9_3;
			case 3:
				return R.drawable.c_9_4;
			}
			break;
		case 9:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_10_1;
			case 1:
				return R.drawable.c_10_2;
			case 2:
				return R.drawable.c_10_3;
			case 3:
				return R.drawable.c_10_4;
			}
			break;
		case 10:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_11_1;
			case 1:
				return R.drawable.c_11_2;
			case 2:
				return R.drawable.c_11_3;
			case 3:
				return R.drawable.c_11_4;
			}
			break;
		case 11:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_12_1;
			case 1:
				return R.drawable.c_12_2;
			case 2:
				return R.drawable.c_12_3;
			case 3:
				return R.drawable.c_12_4;
			}
			break;
		case 12:
			switch (cinfo[1]) {
			case 0:
				return R.drawable.c_13_1;
			case 1:
				return R.drawable.c_13_2;
			case 2:
				return R.drawable.c_13_3;
			case 3:
				return R.drawable.c_13_4;
			}
			break;
		}
		throw new RuntimeException("invalid card");
	}
}
